<?php

namespace Controller\Single;

class Save extends Base {

	public function actionIndex() {
		$this->mustComplete();
		$params = $this->getRouteParams();
		$articleId = !empty($params[0]) ? (int) $params[0] : 0;
		$article = array();
		if ($articleId) {
			$article = \Business\Article::instance()->getDetailById($articleId, false);
			if (!$article) {
				$this->throwException('文章不存在了');
			}
			if ($article['UserId'] != $this->currentUserInfo['UserId']) {
				$this->throwException('你无权修改别人的帖子');
			}
		}

		$this->setCurrentMenuKey('Single');
		$this->setLevelCategories();
		$userBreedId = $this->currentUserInfo['BreedId'];
		$userBreedName = \Business\Breed::instance()->getNameById($userBreedId);

		$this->assign('userBreedName', $userBreedName);
		$this->assign('article', $article);
		$this->display();
	}
}